﻿using System;
/*
 * 操作费重载：实现vector类的相加和1+1大于2的功能
 * 
 * */


namespace HeroDream
{
    class Vector2
    {
        public int x;
        public int y;

        public Vector2(int x,int y)
        {
            this.x = x;
            this.y = y;
        }

        public void OutPut()
        {
            Console.WriteLine($"向量({x},{y})");
        }

      //修饰符 返回值 关键字 需要进行重载的运算符(两个待运算的值)
        public static Vector2 operator +(Vector2 v1,Vector2 v2)
        {
            Vector2 vector = new Vector2(0, 0);
            vector.x = v1.x + v2.x;
            vector.y = v1.y + v2.y;
            return vector;
        }

        public static void Test()
        {
          Vector2 vector201 = new Vector2(0, 2);
          Vector2 vector202 = new Vector2(3, 0);
          Vector2 vector203 = vector201 + vector202;
          vector203.OutPut();

          NewInt a = new NewInt(1);
          NewInt b = new NewInt(1);
          int c = a + b;
          Console.WriteLine(c);
        }
    }

    class NewInt
    {
        int v;
        public NewInt(int v)
        {
            this.v = v;
        }

        public static int operator +(NewInt a,NewInt b)
        {

            return a.v + b.v+1;
        }
    }




}
